use super::*;
#[cfg(test)]
mod tests {
    use crate::lexer_mod::Lexer;
    use crate::parser_mod::Parser;
    #[test]
    ///错误显示测试
    fn err_test() {
        let token_test_string = "123错误定义变量 123_ 123__123 \"test123";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(!lexer.is_legal());
    }
    #[test]
    fn token_test() {
        let token_test_string = "int a=1234;float string []{}()+-*/=<><<>><=>=,;class true false null func if == = . \"string_string\" 12345 123.456 1232_3454 1234.4567 1234567890123456 125612412231512312351211245 123.44";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
    }
    #[test]
    fn math_test() {
        let token_test_string = "int i=(33*44-11)+(64*32/16)-1-2-3-(3+4)/(2+3)";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("math_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn for_test() {
        let token_test_string = "for(int i=0;i=0;i=i+1){}";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("for_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn while_test() {
        let token_test_string = "while(i==2){}";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("while_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn func_test() {
        let token_test_string = "func func_test(int a,int b){}";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("func_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn call_test() {
        let token_test_string = "system.test.call_test(a,b)";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("call_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn return_test() {
        let token_test_string = "{return return_test(a,b);return;}";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("return_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn if_else_test() {
        let token_test_string = "if true {} else {}";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("if_else_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn doc_test() {
        let token_test_string = "\
            ///doc_class的文档描述
            class doc_class{
                ///变量a的描述一
                ///变量a的描述二
                int a = 0;

                ///变量c描述一
                ///变量c描述二
                int c = 0;

                ///call函数的文档描述
                func call(){}
            }";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("doc_test:{:?}\n", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn equals_test() {
        let token_test_string = "{
               b=10>1;
               b=10<1;
               b=10==1;
               b=10!=1;
               b=10>=1;
               b=10<=1;
               }";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("equals_test:{:?}", parser.parse());
        assert!(parser.is_legal());
    }
    #[test]
    fn array_test() {
        let token_test_string = "int[3] a=[1,2,3];";
        let mut lexer = Lexer::new(token_test_string.to_string());
        lexer.read_token();
        assert!(lexer.is_legal());
        let mut parser = Parser::new(lexer.tokens);
        println!("array_test:{:?}", parser.parse());
        assert!(parser.is_legal());
    }
}
